<template>
  <van-row style="margin-top:10px">
    <van-row>
      <van-nav-bar left-arrow @click-left="onClickLeft">
      </van-nav-bar>
      <van-col span="24">
        <van-steps :active="active">
          <van-step>邮箱验证</van-step>
          <van-step>修改密码</van-step>
        </van-steps>
      </van-col>
    </van-row>
    <van-row>
      <component v-bind:is="activeComponent" :onSuccess="onSuccess" :email="email"></component>
    </van-row>
  </van-row>
</template>
<script>
  import checkemail from '../views/user/checkemail'
  import updatepswd from '../views/user/updatepswd'
  import {
    Row,
    Col,
    Field,
    Button,
    Step,
    Steps,
    NavBar
  } from 'vant'
  export default {
    name: 'gorgetpswd',
    components: {
      'van-row': Row,
      'van-col': Col,
      'van-field': Field,
      'van-button': Button,
      'van-steps': Steps,
      'van-step': Step,
      'van-nav-bar': NavBar,
    },
    data: function () {
      return {
        active: 0,
        email: '',
      }
    },
    methods: {
      onClickLeft() {
        this.$router.replace('/login');
      },
      //成功的事件
      onSuccess(obj) {
        console.log(obj);
        this.email = obj.email;
        this.active = obj.active;
      }
    },
    computed: {
      activeComponent() {
        if (this.active == 0) {
          return checkemail;
        } else {
          return updatepswd;
        }
      }
    },
    mounted() {
      //显示底部栏
      this.$store.commit('updateShowFoot', false)
    }
  }

</script>
